package com.chixing.controller;

import com.chixing.service.StoreService;
import com.chixing.util.ServerResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

@Controller
public class StoreController {
    @Autowired
    private StoreService storeService;
    @GetMapping("store")
    public ModelAndView getAll(){
        ServerResponse serverResponse = storeService.getAll();
        ModelAndView mav = new ModelAndView();
        mav.addObject("serverResponse", serverResponse);
        mav.setViewName("car_rental/business_outlets");
        return mav;
    }

    @GetMapping("store/{storeCity}")
    @ResponseBody
    public ServerResponse getStoreByStoreCity(@PathVariable("storeCity") String storeCity){
        return storeService.getStoreByStoreCity(storeCity);
    }
    @GetMapping("get_store/by_id")
    @ResponseBody
    public ServerResponse getStoreByStore(Integer storeId){
        return storeService.getById(storeId);
    }

}